package com.qfedu.dao;

import com.qfedu.model.Developer;
import org.apache.ibatis.annotations.*;
import org.apache.ibatis.mapping.FetchType;

import java.util.Date;
import java.util.List;

public interface DeveloperDao {

    //添加
    @Insert("insert into developer (dname,updatetime,status) values(#{dname},#{updatetime},#{status})")
    void addDeveloper(Developer developer);

    //删除
    @Update("update developer set status =0 where did = #{did}")
    void deleteDeveloper(String did);

    //修改
    @Update("update developer set dname=#{dname},updatetime=#{updatetime},status=#{status} where did=#{did}")
    void updateDeveloper(Developer developer);

    //根据did查询
    @Select("select * from developer where status = 1 and did = #{did}")
    Developer findByDid(String did);

    //查询所有
    @Results(id = "findAllMap",value = {
            @Result(column = "did",property = "did"),
            @Result(column = "dname",property = "dname"),
            @Result(column = "updatetime",property = "updatetime"),
            @Result(column = "status",property = "status"),
            @Result(column = "did",property = "projects",
                    one = @One(select = "com.qf.dao.ProjectDao.findByDid",fetchType = FetchType.EAGER))
    })
    @Select("select * from developer where status = 1")
    List<Developer> findAll();

}